package com.magic.community.controller;

import com.magic.community.dto.PaginationDTO;
import com.magic.community.service.QuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * created by mzk on 2020/07/17
 */
@Controller
public class IndexController {


    @Autowired
    private QuestionService QuestionService;

    @RequestMapping("/")
    public String index( Model model,
                        @RequestParam(name = "page", defaultValue = "1") Integer page,
                        @RequestParam(name = "size",defaultValue = "5") Integer size) {

        PaginationDTO pagination = QuestionService.list(page,size);
        model.addAttribute("pagination", pagination);

        return "index";
    }

}
